package com.xsr.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project sssm
 * @date 2022/9/17 10:51
 */
@Controller
@RequestMapping("/User")
public class UserController {
    @RequestMapping("/login")
    public String login(String username,String password){
        System.out.println("你是个傻逼");
        System.out.println("你是个大傻逼");
        System.out.println("我我我我我我啊啊啊啊");
        String pwd = new Md5Hash(password, "xsr", 1024).toString();
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, pwd.toCharArray());
        subject.login(usernamePasswordToken);
        System.out.println("登陆成功");
        return "loginSuccess";

    }
}
